<template>
  <main class="main">
    <section class="section1">
      你正在预览{{ cityName }}的天气信息
      <span>，可以通过右上角的"+"号按钮保存起来</span>
    </section>
    <section class="section2 container">
      <h1>当日气温是：{{ currentWeather.temperature }}摄氏度</h1>
      <h1>当日天气是：{{ currentWeather.weather }}</h1>
      <h1>当日风向是：{{ currentWeather.winddirection }}风</h1>
      <h1>当日风力是：{{ currentWeather.windpower }}级</h1>
    </section>
    <hr />
    <div class="section3 container">
      <CityWeatherChart />
    </div>
  </main>
</template>

<script setup>
import {ref} from 'vue'
import CityWeatherChart from '@/components/CityWeatherChart.vue'
import { useRoute } from 'vue-router'
const route = useRoute()

const cityName = ref(route.query.search)  // 查询城市名称

// 引入天气 store
import { useWeatherStore } from '@/store/index.js'
const weatherStore = useWeatherStore()

// 当天天气数据渲染
import {computed} from 'vue'
const currentWeather = computed(() => weatherStore.currentSearchCity)
</script>

<style scoped>
.main {
  display: flex;
  flex-direction: column;
  color: #fff;
}
.main .section1 {
  background-color: #004e71;
  padding: 0.5rem;
  text-align: center;
}

.container {
  box-sizing: border-box;
}
@media (min-width: 640px) {
  .header .container {
    max-width: 640px;
  }
}
@media (min-width: 768px) {
  .header .container {
    max-width: 768px;
  }
}
@media (min-width: 1024px) {
  .header .container {
    max-width: 1024px;
  }
}
@media (min-width: 1280px) {
  .container {
    max-width: 1280px;
  }
}
@media (min-width: 1536px) {
  .container {
    max-width: 1536px;
  }
}

.main .section2 {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  margin: 0 auto;
  margin-top: 1.5rem;
  padding: 0 10rem;
  text-align: center;
  h1 {
    margin: 0;
    font-size: inherit;
    font-weight: inherit;
  }
}

hr {
  width: 100%;
  border-bottom: 0;
  border-left: 0;
  border-right: 0;
  margin-top: 1.5rem;
  margin-bottom: 0;
}
.main .section3 {
  width: 100%;
  margin: 0 auto;
  padding: 0 10rem;
}

</style>
